package gameobjects
{
	import assets.Globals;
	
	import com.greensock.TweenMax;
	import com.greensock.easing.Linear;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class TowerProjectileTwo extends TowerProjectile
	{
		private var myMovie:gunnerprojectile = new gunnerprojectile();
		
		public function TowerProjectileTwo(dmgHP:Number=45, dmgSlow:Number=0, dmgShield:Number=0, passThrough:Boolean=false, passHops:int=2)
		{
			super(dmgHP, dmgSlow, dmgShield, passThrough, passHops);
			
			addChild(myMovie);
			
			cs.x = 17;
			cs.y = 17;
			cs.graphics.beginFill(0xFF0000);
			cs.graphics.drawCircle(0, 0, 10);
			cs.graphics.endFill();
			cs.alpha = 0;
			
			myMovie.walk();
			
			addChild(cs);
		}
		
		override protected function init(event:Event):void
		{
			myTween = new TweenMax(this, 5, {  x: x+800, y : y, ease:Linear.easeNone });
			Globals.projectiles.push(this);
		}
		
		override public function destroy():void
		{
			myTween.kill();
			Globals.projectiles.splice(Globals.projectiles.indexOf(this), 1);
			
			var destructionTimer:Timer = new Timer(400, 1);
			destructionTimer.addEventListener("timer", destruction);
			destructionTimer.start();
			
			myMovie.die();
		}
		
		private function destruction(event:TimerEvent):void
		{
			super.destroy();
		}
	}
}